package com.le.tester.javaThink.fourth.concurrency;

/**
 * createTime：2021/9/13 16:38
 * description：简单的线程使用
 */
public class SimpleThread extends Thread {

    private int countDown = 5;
    private static int threadCount = 0;

    public SimpleThread() {
        super(Integer.toString(++threadCount));
        start();
    }

    @Override
    public String toString() {
        return "SimpleThread{" +
                "countDown=" + countDown +
                '}';
    }

    @Override
    public void run() {
        while (true) {
            System.out.println(this);
            if (--countDown == 0)
                return;
        }

    }

    public static void main(String[] args) {
        for (int i = 0; i < 5; i++) {
            new SimpleThread();
        }
    }
}
